package com.matt.controller.web;

import com.matt.domain.course.Course;
import com.matt.commons.model.StatusResponse;
import com.matt.foundation.query.CoursePlanQuery;
import com.matt.service.CourseNurseryService;
import com.matt.service.CoursePlanClassesService;
import com.matt.service.CoursePlanTopicService;
import com.matt.service.CourseService;

import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/3/12
 * *******************************
 */
@RestController
@RequestMapping("/web/course_nursery")
public class WebCourseNurseryController {

    @Autowired
    private CourseService courseService;

    @Autowired
    private CourseNurseryService courseNurseryService;

    @Autowired
    private CoursePlanClassesService coursePlanClassesService;

    @Autowired
    private CoursePlanTopicService coursePlanTopicService;
//
//    @ApiOperation(value = "获取托班课程类型",httpMethod = "POST")
//    @RequestMapping("/all_type")
//    public StatusResponse allType() {
//        List<Map> areaPublicAllType = courseService.findOfficialAllTypeActive();
//        return StatusResponse.success(areaPublicAllType);
//    }
//
//    @ApiOperation(value = "获取托班课程",httpMethod = "POST")
//    @RequestMapping("/by_type_name")
//    public StatusResponse byTypeName(String typeName) {
//        List<Course> officialList = courseService.findOfficialByTypeName(typeName);
//        return StatusResponse.success(officialList);
//    }

    @ApiOperation(value = "创建托班课程",httpMethod = "POST")
    @RequestMapping("/create")
    public StatusResponse create(String areaId, String topicId, String courseId, Integer courseType, String date, String beginTime, String endTime) {
        Boolean result = coursePlanClassesService.createNursery(topicId, courseType, date, beginTime, endTime, courseId, areaId);
        return StatusResponse.success(result);
    }

    @ApiOperation(value = "删除托班课程",httpMethod = "POST")
    @RequestMapping("/delete")
    public StatusResponse delete(String coursePlanNurseryId) {
        Boolean result = coursePlanTopicService.delete(coursePlanNurseryId);
        return StatusResponse.success(result);
    }
//    @ApiOperation(value = "我的托班课程表",httpMethod = "POST")
//    @RequestMapping("/plan_list")
//    public StatusResponse planList(@RequestHeader(TICKET) String ticket, ClassesCoursePlanQuery query){
//        StaffDTO baseInfo = ssoCallService.getStaff(ticket);
//        query.setStaffId(baseInfo.getId());
//        query.setAreaId(baseInfo.getAreaId());
//        Page<WebCoursePlanNurseryListVo> coursePlanNurseryList;
//        if (query.getType() == 1)
//             coursePlanNurseryList = courseNurseryService.getWebCoursePlanList(query);
//        else
//            coursePlanNurseryList = courseNurseryService.getWebCoursePlanHistory(query);
//
//
//        return StatusResponse.success(coursePlanNurseryList);
//    }

//    @ApiOperation(value = "托班课程详情",httpMethod = "POST")
//    @RequestMapping("/plan_detail")
//    public StatusResponse planDetail(@RequestHeader(TICKET) String ticket, String planClassesId){
//        Map response = courseNurseryService.getWebCoursePlanDetail(planClassesId);
//        return StatusResponse.success(response);
//    }

    @ApiOperation(value = "托班和早教课程总数",httpMethod = "POST")
    @RequestMapping("/get_course_count")
    public StatusResponse getAllCount(CoursePlanQuery query) {
        long earlyAndNurseryAllCount = courseNurseryService.getEarlyAndNurseryAllCount(query);
        return StatusResponse.success(earlyAndNurseryAllCount);
    }


}
